namespace Kopernikus.Parsing.Utility
{
    public class LazyMember<T> where T : class
    {
        #region Delegates

        public delegate T LazyMemberCreationDelegate();

        #endregion

        private readonly LazyMemberCreationDelegate m_createAction;
        private T m_member;

        public LazyMember(LazyMemberCreationDelegate createAction)
        {
            m_createAction = createAction;
        }

        public T Member
        {
            get
            {
                if (m_member == null)
                {
                    m_member = m_createAction();
                }
                return m_member;
            }
        }
    }
}